package com.cloud.wms.ui.main.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.chad.library.adapter.base.entity.node.BaseNode;
import com.cloud.wms.config.TaskCode;

import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * @Author:Chen
 * @Date: 2021-01-19 11:35
 * @Description:
 */
public class TaskEntity extends BaseNode implements Parcelable {

    /**
     * workID	integer($int32)
     * 工作单ID
     * <p>
     * taskID	integer($int32)
     * 任务ID
     * <p>
     * taskCode	string
     * nullable: true
     * 任务编码
     * <p>
     * taskShortName	string
     * nullable: true
     * 任务简称
     * <p>
     * taskSource	integer($int32)
     * nullable: true
     * 任务来源
     * <p>
     * companyID	integer($int32)
     * nullable: true
     * 所属公司
     * <p>
     * warehouseID	integer($int32)
     * nullable: true
     * 所属仓库
     * <p>
     * memberID	integer($int32)
     * nullable: true
     * 所属会员
     * <p>
     * waveType	integer($int32)
     * nullable: true
     * 波次类型
     * <p>
     * billID	integer($int32)
     * nullable: true
     * 关联单据ID
     * <p>
     * billCode	string
     * nullable: true
     * 关联单据号
     * <p>
     * taskAttribute	integer($int32)
     * nullable: true
     * 任务属性
     * <p>
     * parentTaskID	integer($int32)
     * 父任务ID
     * <p>
     * taskMode	integer($int32)
     * nullable: true
     * 任务模式
     * <p>
     * executorType	integer($int32)
     * nullable: true
     * 执行对象类型
     * <p>
     * jobStationID	integer($int32)
     * 执行岗位
     * <p>
     * executorID	integer($int32)
     * nullable: true
     * 执行对象ID
     * <p>
     * totalQuantity	integer($int32)
     * nullable: true
     * 任务总量
     * <p>
     * completedQuantity	integer($int32)
     * nullable: true
     * 已完成量
     * <p>
     * beginTime	string($date-time)
     * nullable: true
     * 开始时间
     * <p>
     * completeTime	string($date-time)
     * nullable: true
     * 完成时间
     * <p>
     * status	integer($int32)
     * nullable: true
     * 状态
     * <p>
     * lastTaskID	integer($int32)
     * nullable: true
     * 上一个任务ID
     * <p>
     * url	string
     * nullable: true
     * PDA绑定地址
     * <p>
     * creater	integer($int32)
     * nullable: true
     * 创建人ID
     * <p>
     * createDate	string($date-time)
     * nullable: true
     * 创建时间
     * <p>
     * appKey	string
     * nullable: true
     * AppKey
     * <p>
     * sortType	integer($int32)
     * nullable: true
     * 分拣类型
     * <p>
     * collectionMode	integer($int32)
     * nullable: true
     * 领用模式
     * <p>
     * warehouseAreaID	integer($int32)
     * nullable: true
     * 库区ID
     * <p>
     * productCategory	integer($int32)
     * nullable: true
     * 生产组别
     * <p>
     * memo	string
     * nullable: true
     * 任务信息
     */

    private long workID;
    private long mainWorkID;
    private long taskID;
    private String taskCode;
    private String taskShortName;
    private int taskSource;
    private long companyID;
    private long warehouseID;
    private long memberID;
    private String memberName;
    private int waveType;
    private long billID;
    private String billCode;
    private long parentTaskID;
    private int taskMode;
    private int executorType;
    private long jobStationID;
    private long executorID;
    private int totalQuantity;
    private int completedQuantity;
    private String beginTime;
    private String completeTime;
    private int status;
    private long lastTaskID;
    private String url;
    private int creater;
    private String createDate;
    private String appKey;
    private int sortType;
    private long warehouseAreaID;
    private int productCategory;
    private String memo;
    private long mainBillID;
    private String mainBillCode;

    public long getMainWorkID() {
        return mainWorkID;
    }

    public void setMainWorkID(long mainWorkID) {
        this.mainWorkID = mainWorkID;
    }

    public long getMainBillID() {
        return mainBillID;
    }

    public void setMainBillID(long mainBillID) {
        this.mainBillID = mainBillID;
    }

    public String getMainBillCode() {
        return mainBillCode;
    }

    public void setMainBillCode(String mainBillCode) {
        this.mainBillCode = mainBillCode;
    }

    public String getMemberName() {
        return memberName == null ? "" : memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public long getWorkID() {
        return workID;
    }

    public void setWorkID(long workID) {
        this.workID = workID;
    }

    public long getTaskID() {
        return taskID;
    }

    public void setTaskID(long taskID) {
        this.taskID = taskID;
    }

    public String getTaskCode() {
        return taskCode == null ? "" : taskCode;
    }

    // 是否为订单分拣
    public boolean isOrderSort() {
        return TaskCode.CODE_003001.equalsIgnoreCase(getTaskCode()) && getWaveType() == 1;
    }

    public void setTaskCode(String taskCode) {
        this.taskCode = taskCode;
    }

    public String getTaskShortName() {
        return taskShortName == null ? "" : taskShortName;
    }

    public void setTaskShortName(String taskShortName) {
        this.taskShortName = taskShortName;
    }

    public int getTaskSource() {
        return taskSource;
    }

    public void setTaskSource(int taskSource) {
        this.taskSource = taskSource;
    }

    public long getCompanyID() {
        return companyID;
    }

    public void setCompanyID(long companyID) {
        this.companyID = companyID;
    }

    public long getWarehouseID() {
        return warehouseID;
    }

    public void setWarehouseID(long warehouseID) {
        this.warehouseID = warehouseID;
    }

    public long getMemberID() {
        return memberID;
    }

    public void setMemberID(long memberID) {
        this.memberID = memberID;
    }

    public int getWaveType() {
        return waveType;
    }

    public void setWaveType(int waveType) {
        this.waveType = waveType;
    }

    public long getBillID() {
        return billID;
    }

    public void setBillID(long billID) {
        this.billID = billID;
    }

    public String getBillCode() {
        return billCode == null ? "" : billCode;
    }

    public void setBillCode(String billCode) {
        this.billCode = billCode;
    }

    public long getParentTaskID() {
        return parentTaskID;
    }

    public void setParentTaskID(long parentTaskID) {
        this.parentTaskID = parentTaskID;
    }

    public int getTaskMode() {
        return taskMode;
    }

    public void setTaskMode(int taskMode) {
        this.taskMode = taskMode;
    }

    public int getExecutorType() {
        return executorType;
    }

    public void setExecutorType(int executorType) {
        this.executorType = executorType;
    }

    public long getJobStationID() {
        return jobStationID;
    }

    public void setJobStationID(long jobStationID) {
        this.jobStationID = jobStationID;
    }

    public long getExecutorID() {
        return executorID;
    }

    public void setExecutorID(long executorID) {
        this.executorID = executorID;
    }

    public int getTotalQuantity() {
        return totalQuantity;
    }

    public void setTotalQuantity(int totalQuantity) {
        this.totalQuantity = totalQuantity;
    }

    public int getCompletedQuantity() {
        return completedQuantity;
    }

    public void setCompletedQuantity(int completedQuantity) {
        this.completedQuantity = completedQuantity;
    }

    public String getBeginTime() {
        return beginTime == null ? "" : beginTime;
    }

    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }

    public String getCompleteTime() {
        return completeTime == null ? "" : completeTime;
    }

    public void setCompleteTime(String completeTime) {
        this.completeTime = completeTime;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public long getLastTaskID() {
        return lastTaskID;
    }

    public void setLastTaskID(long lastTaskID) {
        this.lastTaskID = lastTaskID;
    }

    public String getUrl() {
        return url == null ? "" : url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getCreater() {
        return creater;
    }

    public void setCreater(int creater) {
        this.creater = creater;
    }

    public String getCreateDate() {
        return createDate == null ? "" : createDate.replace("T", " ");
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public String getAppKey() {
        return appKey == null ? "" : appKey;
    }

    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }

    public int getSortType() {
        return sortType;
    }

    public void setSortType(int sortType) {
        this.sortType = sortType;
    }

    public long getWarehouseAreaID() {
        return warehouseAreaID;
    }

    public void setWarehouseAreaID(long warehouseAreaID) {
        this.warehouseAreaID = warehouseAreaID;
    }

    public int getProductCategory() {
        return productCategory;
    }

    public void setProductCategory(int productCategory) {
        this.productCategory = productCategory;
    }

    public String getMemo() {
        return memo == null ? "" : memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    @Nullable
    @Override
    public List<BaseNode> getChildNode() {
        return null;
    }

    public TaskEntity() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.workID);
        dest.writeLong(this.mainWorkID);
        dest.writeLong(this.taskID);
        dest.writeString(this.taskCode);
        dest.writeString(this.taskShortName);
        dest.writeInt(this.taskSource);
        dest.writeLong(this.companyID);
        dest.writeLong(this.warehouseID);
        dest.writeLong(this.memberID);
        dest.writeString(this.memberName);
        dest.writeInt(this.waveType);
        dest.writeLong(this.billID);
        dest.writeString(this.billCode);
        dest.writeLong(this.parentTaskID);
        dest.writeInt(this.taskMode);
        dest.writeInt(this.executorType);
        dest.writeLong(this.jobStationID);
        dest.writeLong(this.executorID);
        dest.writeInt(this.totalQuantity);
        dest.writeInt(this.completedQuantity);
        dest.writeString(this.beginTime);
        dest.writeString(this.completeTime);
        dest.writeInt(this.status);
        dest.writeLong(this.lastTaskID);
        dest.writeString(this.url);
        dest.writeInt(this.creater);
        dest.writeString(this.createDate);
        dest.writeString(this.appKey);
        dest.writeInt(this.sortType);
        dest.writeLong(this.warehouseAreaID);
        dest.writeInt(this.productCategory);
        dest.writeString(this.memo);
        dest.writeLong(this.mainBillID);
        dest.writeString(this.mainBillCode);
    }

    public void readFromParcel(Parcel source) {
        this.workID = source.readLong();
        this.mainWorkID = source.readLong();
        this.taskID = source.readLong();
        this.taskCode = source.readString();
        this.taskShortName = source.readString();
        this.taskSource = source.readInt();
        this.companyID = source.readLong();
        this.warehouseID = source.readLong();
        this.memberID = source.readLong();
        this.memberName = source.readString();
        this.waveType = source.readInt();
        this.billID = source.readLong();
        this.billCode = source.readString();
        this.parentTaskID = source.readLong();
        this.taskMode = source.readInt();
        this.executorType = source.readInt();
        this.jobStationID = source.readLong();
        this.executorID = source.readLong();
        this.totalQuantity = source.readInt();
        this.completedQuantity = source.readInt();
        this.beginTime = source.readString();
        this.completeTime = source.readString();
        this.status = source.readInt();
        this.lastTaskID = source.readLong();
        this.url = source.readString();
        this.creater = source.readInt();
        this.createDate = source.readString();
        this.appKey = source.readString();
        this.sortType = source.readInt();
        this.warehouseAreaID = source.readLong();
        this.productCategory = source.readInt();
        this.memo = source.readString();
        this.mainBillID = source.readLong();
        this.mainBillCode = source.readString();
    }

    protected TaskEntity(Parcel in) {
        this.workID = in.readLong();
        this.mainWorkID = in.readLong();
        this.taskID = in.readLong();
        this.taskCode = in.readString();
        this.taskShortName = in.readString();
        this.taskSource = in.readInt();
        this.companyID = in.readLong();
        this.warehouseID = in.readLong();
        this.memberID = in.readLong();
        this.memberName = in.readString();
        this.waveType = in.readInt();
        this.billID = in.readLong();
        this.billCode = in.readString();
        this.parentTaskID = in.readLong();
        this.taskMode = in.readInt();
        this.executorType = in.readInt();
        this.jobStationID = in.readLong();
        this.executorID = in.readLong();
        this.totalQuantity = in.readInt();
        this.completedQuantity = in.readInt();
        this.beginTime = in.readString();
        this.completeTime = in.readString();
        this.status = in.readInt();
        this.lastTaskID = in.readLong();
        this.url = in.readString();
        this.creater = in.readInt();
        this.createDate = in.readString();
        this.appKey = in.readString();
        this.sortType = in.readInt();
        this.warehouseAreaID = in.readLong();
        this.productCategory = in.readInt();
        this.memo = in.readString();
        this.mainBillID = in.readLong();
        this.mainBillCode = in.readString();
    }

    public static final Creator<TaskEntity> CREATOR = new Creator<TaskEntity>() {
        @Override
        public TaskEntity createFromParcel(Parcel source) {
            return new TaskEntity(source);
        }

        @Override
        public TaskEntity[] newArray(int size) {
            return new TaskEntity[size];
        }
    };
}
